﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tinh_giai_thua
{
    class ToHop
    {
       
        public int NhapK()
        {
            int K;
            Console.Write("nhap so k: ");
            K = Convert.ToInt16(Console.ReadLine());
            while (K > 8 || K <= 0)
            {

                Console.WriteLine("nhap lai so <8");
                K= Convert.ToInt16(Console.ReadLine());
            }
            return K;
            
         
        }
        public int NhapN()
        {
            int N;
            Console.Write("nhap so n: ");
            N = Convert.ToInt16(Console.ReadLine());
            while (N > 8 || N <= 0)
            {

                Console.WriteLine("nhap lai so <8");
                N = Convert.ToInt16(Console.ReadLine());
            }
            return N;

        }
        public int giaithua(int B)
        {
            int KQ = 1;
            for (int i = 1; i <= B; i++)
            {
                KQ = KQ * i;

            }
            return KQ;
        }
        public long TinhToHop(int N, int K)
        {
            long KQ=1;
            KQ= giaithua(N)/(giaithua(K)*giaithua(N-K));
            return KQ;
        }
        
    
    }
}
